<template>
  <div>
    <van-nav-bar
        title="评论"
        left-arrow
        @click-left="onBack"
        fixed
    />
    <div style="margin-top: 50px">
      <!--    <van-cell title="书评" is-link @click="goToWriteReview" />-->
      <van-cell v-for="(review, index) in reviews" :key="index">
        <div>
          <van-image style="width: 50px;height: 50px;float: left" :src="review.userurl" round/>
          <span style="margin-left: 20px;float: left">{{ review.username }}</span>
          <div style="float: left;margin-top: 25px;margin-left: -45px">
            <van-rate v-model="review.score/2" readonly allow-half color="#ffd21e" void-icon="star" void-color="#eee"/>
          </div>

          <div>
            <span style="float: left;margin-top: 20px;width: 100%">{{ review.comment }}</span>
          </div>
          <div>
            <span style="float: left;margin-top: 20px">{{ review.commenttime }}</span>
            <van-icon style="float: right;margin-top: 20px" size="20px" name="chat-o" @click="showComment(review.id)"/>
          </div>
        </div>
      </van-cell>
    </div>
  </div>


</template>

<script>
import axios from "axios";

export default {
  name: "Writereview",
  data() {
    return {
      reviews: [],
    }
  },
  methods: {

    showComment(id){
      this.$router.push({path: '/novelreplyuser',query: {pid: id,id:this.$route.query.id}})
    },

    findReviews(){
       let user = localStorage.getItem('user');
       let user1=JSON.parse(user);
      axios.post('http://localhost:9999/api-novel/score/findalluser?uid='+user1.id).then(res => {
        if (res.data.code == 1) {
          this.reviews = res.data.data;
        }
      })
    },

    onBack(){
      this.$router.push('/mine');
    },
  },
  created() {
    // this.fetchData();
    this.findReviews()
  }
}
</script>


<style scoped>

</style>